import api from '@/http/index'

/* 商品分类树 */
export const getCategories = (data) => {
    return new Promise((resolve, reject) => {
        api.get('/api/Category/GetTreeJson', data).then((res) => {
            resolve(res);
        }).catch(err => {
            reject(err)
        })
    });
};
/* 商品分类列表 */
export const getTablesList = (data) => {
    return new Promise((resolve, reject) => {
        api.get('/api/Category/GetTreeGridJson', data).then((res) => {
            resolve(res);
        }).catch(err => {
            reject(err)
        })
    });
};

/* 新建 */
export const addTablesItem = (data) => {
    return new Promise((resolve, reject) => {
        api.post('/api/Category/SubmitForm', data).then((res) => {
            resolve(res);
        }).catch(err => {
            reject(err)
        })
    });
};

/* 删除字典 */
export const deleteItem = (data) => {
    return new Promise((resolve, reject) => {
        api.post('/api/Category/DeleteForm', data).then((res) => {
            resolve(res);
        }).catch(err => {
            reject(err)
        })
    });
};


/* 根据id查询 */
export const getItemInfo = (data) => {
    return new Promise((resolve, reject) => {
        api.post('/api/Category/GetFormJson', data).then((res) => {
            resolve(res);
        }).catch(err => {
            reject(err)
        })
    });
};

/* 停用启用 */
export const setDisableEnable = (data) => {
    return new Promise((resolve, reject) => {
        api.post('/api/Category/Activite', data).then((res) => {
            resolve(res);
        }).catch(err => {
            reject(err)
        })
    });
};

